local skel = fk.CreateSkill {
  name = "emo__jiaolang",
}

Fk:loadTranslationTable{
  ["emo__jiaolang"] = "搅浪",
  [":emo__jiaolang"] = "出牌阶段限一次，你可以令从下家起每名角色依次移动场上一张牌。",

  ["#emo__jiaolang"] = "搅浪:令每名角色依次移动场上一张牌(从下家开始，你最后移)",
  ["#emo__jiaolang-move"] = "搅浪:请场上一张牌",

  ["$emo__jiaolang1"] = "",
  ["$emo__jiaolang2"] = "",
}

skel:addEffect("active", {
  anim_type = "control",
  prompt = "#emo__jiaolang",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    if player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0 then
      local players = Fk:currentRoom().alive_players
      for _, from in ipairs(players) do
        for _, p in ipairs(players) do
          if p ~= from and from:canMoveCardsInBoardTo(p) then
            return true
          end
        end
      end
    end
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local players = room:getAlivePlayers()
    table.removeOne(players, player)
    table.insert(players, player)
    for _, p in ipairs(players) do
      if #room:canMoveCardInBoard() == 0 then break end
      local tos = room:askToChooseToMoveCardInBoard(p, {
        skill_name = skel.name, cancelable = false
      })
      if #tos == 2 then
        room:askToMoveCardInBoard(p, {skill_name = skel.name, target_one = tos[1], target_two = tos[2] })
      end
    end
  end,
})

return skel
